<template>
	<view class='pages'>
		<scroll-view scroll-y="true" class='contentbox' @scrolltolower="scrolltolower">
			<view v-if="list.length == 0">
				<view style="height: 100rpx;"></view>
				<u-empty text=" - 暂无数据 - " mode="list"></u-empty>
			</view>
			<view class="uniFlex boxes" v-for="(item,index) in list" :key="index" @click="detail(item.id)">
				<img :src="item.image" alt="" />
				<view class="newmsg">
					<view>{{item.title}}</view>
					<view>{{item.typestr?item.typestr:''}}</view>
					<view>{{item.author?item.author:''}}</view>
					<view>{{item.create_time}}</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				page: 1,
				limit: 20,
				length: true,
				list: [
					
				],
			}
		},
		async onLoad() {
			await this.getList();
		},
		methods: {
			// 上拉
			scrolltolower() {
				console.log('触底')
				if (this.length) {
					this.page++
					this.getList();
				}
			},
			// 列表
			async getList() {
				let res = await this.$api.newlists({
					page_no: this.page,
					page_size: this.limit,
				});
				if (res.code == 1) {
					this.length = res.data.lists.length == this.limit;
					this.list.push(...res.data.lists);
				}
			},
			detail(id){
				uni.navigateTo({
					url:'/pages/index/detail/detail?id='+id
				})
			}
		}
	}
</script>

<style scoped lang="less">
	.pages {
		position: absolute;
		left: 0;
		top: 0;
		width: 100%;
		height: 100%;
		overflow: hidden;
		display: flex;
		flex-direction: column;
	}
	.contentbox {
		flex: 1;
		overflow: hidden;
		padding: 20rpx 15rpx;

		.boxes {
			padding: 30rpx 23rpx;
			background: #fff;
			margin-bottom: 20rpx;
			
			img{
				width: 240rpx;
				height: 180rpx;
				margin-right: 30rpx;
			}
			.newmsg{
				width: 400rpx;
				
				view:nth-child(1) {
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 800;
					color: #000000;
					line-height: 36rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
				}
				view:nth-child(2) {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #000000;
					line-height: 36rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					margin: 10rpx 0;
				}
				view:nth-child(3) {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #000000;
					line-height: 36rpx;
					white-space: nowrap;
					overflow: hidden;
					text-overflow: ellipsis;
					margin-bottom: 10rpx;
				}
				view:nth-child(4) {
					font-size: 28rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #878787;
				}
			}
		}
	}
</style>